package com.autonomous_printer.mapper;

import com.autonomous_printer.pojo.Order;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface OrderMapper {

    @Select("select * from order_msg order by id desc")
    public List<Order> queryAllOrder();

    @Select("select * from order_msg where id=#{id}")
    public Order queryOderById(@Param("id") int id);

    @Select("select count(*) from order_msg")
    public int queryOrderNum();

    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    @Insert("insert into order_msg(file_id,order_no,trade_no,money,status,datetime) " +
            "value (#{fileId},#{orderNo},#{tradeNo},#{money},#{status},#{datetime})")
    public int addOrder(Order order);

    @Update("update order_msg set status=1 where id=#{id}")
    public int updateOrderStatus(@Param("id") int id);
}
